Hello and welcome to this lecture.
In this lecture we will be creating a function that we will use to draw the paddle.
I am going to create a function now called draw paddle wing creative functions is geared to name your
functions appropriately.
So the closer the name is to what you're trying to do that better.
For example here we've got a function called drop ball.
So is self-explanatory we know what that function scanner too.
So what I'm going to do to create the drop pad of function I'm just going to copy this entire function
here and just change some of the values just to save some time here.
So I just go paste I'm going to change is to drop pando.
All right so I've changed the name to draw a paddle an hour leave a lot of the most fun challenge you
can have a big in parts of this is a contents contexts don't begin part and then where we go.
We're not going to do an arc.
This was what we used to quit the ball.
What we're trying to do is create a paddle so gonna use the wreck to see context or rest for rectangle.
And then in between the parentheses we are going to create the valleys are the parameters that will
be used to create the paddle.
All right the first time if I'm gonna pass into this context are wrecked is the paddle x variable type
in paddle and is upper case X. The next time if I'm going to include is the height of the canvas minus
the paddle height.
When will the time being come that's
come as dropped Heights which means the height of the canvas minus paddle height.
But we've got a variable here core puddle height so angle of mine was the height of the -- bus from
the paddle height comma the next week go into parsee is the width of the paddle we go.
PAOLO We have already got a variable called paddle.
We've defined their necks.
We're going to apply the puddle height variable power do.
Right.
All right so file in these creation of the paddle in the contents are wrecked.
We have got several perimeters.
We've caught the paddle.
EX What time is the starting point for the x axis.
And then we've got the cumbersome height which is the height of the Cambers minus the paddle height
command and then we have also passed in another on apparently which is a paddle with and then pass then
the paddle height as well.
Next we want to apply a context feel the colour will use to collar the iPad.
I will make it blue.
You can make yours whatever you like.
I just make my blue.
And then this is what will actually do the fill in this method here.
Context Dr. Phil hand there.
We've got that.
That will close.
We've got begin and then go closer.
This closes the function so you can see how much pull a semicolon at the end of each line.
It's very important that the cause would just grip and most programming language they work with instructions
line by line so that indicates that these instructions on this line is finished.
And then he jumps on to the next line.
So we have now drawn created a function to draw the panel.
OK so this is a function to create the sort of click on save to save your work so far.
I've saved my work if I refresh you.
You should not see the iPad or yet.
OK.
We have defined the function we have created a function that would draw the paddle.
The paddle is not visible on the canvas yet that is because we have not called it a dot We've created
it.
We need to call it into action.
So to do that we are going to insert it.
We need we need to insert a line that will core this function to draw the podium so let's do that.
All right to call the function we've just created the drop pad of function we need to call it from the
draw function we've got a function here called draw where we've got a draw ball here defined this is
where we call all called the draw ball function.
So to call the draw paddle functioning to action we need to call it from here.
So I just type in draw
grew up had a very good list and then just grab a pad and then kind of semigroups k if i say that the
fact that means I've saved that and refresh my browser.
You should call this function here and he will draw it paddles so this function drop calls to function
causing trouble to drop the ball and it was all core.
The drop paddle to draw the paddle.
So lets me refresh and you can see.
You can see that that's the shadow they are do a paddle has got no action.
It does move at the moment by Lyss.
We've drawn the paddle thank you so much for your time in this lecture.
Please let me know if you've got any questions whatsoever.
In the next lecture we are going to be creating some control that will use to control the puddle.